/**************************
* @Summary 测试类函数的实现
* @Author 20009200303 赵传博
* @Date 2022/3/22
*****************************/
#include "Test.h"
void Test::testPeople() {
    string _name;
    double value;
    list<People> peopleList;
    while(true){
        cin >> _name; if(!cin) break;
        cin >> value; if(!cin) break;
        //cout << "Entering " << name << " and " << value << endl;
        People people(_name, value);
        list<People>::iterator p;
        for(p = peopleList.begin(); p != peopleList.end(); ++p){
            if(p->getName() == _name){
                //cout << "Test" << endl;
                p->addVal(value);
                break;
            }
        }
        /* 如果没有重名的，则插入到list尾部 */
        if(p == peopleList.end()){
            people.setAvg(value);
            //cout << "Reach end" << endl;
            peopleList.push_back(people);
        }
    }
    for(auto p : peopleList){
        cout << p.getName() << " val: " << p.getVal() << " avg: " << p.getAvg() << endl;
    }
}

void Test::testAtoi() {
    string array;
    cin >> array;
    int num = AtoiUtil::myAtoi(array);
    cout << num << endl;
}

void Test::testItoa() {
    int i;
    cin >> i;
    char* b = new char[100];
    ItoaUtil::myItoa(i, b);
    cout << b << endl;
}


